package com.autonavi.yunda.yunji.core.engine.context;

import org.apache.commons.lang3.tuple.Pair;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;

import java.util.List;

/**
 * @author cizhong.wcs
 * @date 2023/10/27 11:20
 */
public class EngineTransactionContext {
    List<Pair<PlatformTransactionManager, TransactionStatus>> transactions;

    public EngineTransactionContext(List<Pair<PlatformTransactionManager, TransactionStatus>> transactions) {
        this.transactions = transactions;
    }

    public void commit() {
        transactions.forEach(p -> p.getLeft().commit(p.getRight()));
    }

    public void rollback() {
        transactions.forEach(p -> p.getLeft().rollback(p.getRight()));
    }


}
